#!/bin/bash

set -o pipefail
set -o errexit
set -o errtrace

export LC_ALL=C

ANNOTATE_DIR=$1

source 6_annotation/annotate_common.sh

NORM_MATRIX_DIR=${BASE_DATA_PATH}/4_normed_matrix/${BASE_DATE}/wu_blast_nw
GENOMES_NUM=`cat "${NORM_MATRIX_DIR}/map_int_genom.txt" | wc -l`

read_and_prepare_input          $ANNOTATE_DIR
find_local_alignments_wu_blast  $ANNOTATE_DIR
find_global_alignments_nw_extra $ANNOTATE_DIR


for Z_VALUE in 5; do
    E_DIR=$ANNOTATE_DIR/e_$Z_VALUE
    mkdir -p $E_DIR

    create_vectors_nw      $ANNOTATE_DIR    $E_DIR    $Z_VALUE    $NORM_MATRIX_DIR
    find_sim_vectors_raw                    $E_DIR    $Z_VALUE    $NORM_MATRIX_DIR   $GENOMES_NUM
    find_sim_vectors                        $E_DIR    $Z_VALUE    $NORM_MATRIX_DIR
    #create_kegg_limited                     $E_DIR    $Z_VALUE    "1e-7"
    #create_gene_functions                   $E_DIR    $Z_VALUE
    #create_gene_functions_kegg              $E_DIR    $Z_VALUE
    #create_gene_functions_uniq              $E_DIR    $Z_VALUE
    #create_gene_functions_best_uniq         $E_DIR    $Z_VALUE
    #create_gene_functions_best_uniq_kegg    $E_DIR    $Z_VALUE
    create_gene_ontology                    $E_DIR    $Z_VALUE    "1e-6"
    clear_tmp_files                         $E_DIR
    #create_gene_pathways                    $E_DIR    $Z_VALUE
    #create_gene_pathways_avg_nw             $E_DIR    $Z_VALUE    $GENOMES_NUM

done


